//
//  BankCardViewController.m
//  fxxiaoke
//
//  Created by 鞠超 on 16/9/26.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "BankCardViewController.h"

#import "Add_BankCardViewController.h"

@interface BankCardViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView * tableView;

@property (nonatomic, strong) UIView * view_Head;

@end

@implementation BankCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void )p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    
    _lblTitle.text = @"银行卡";
    
    //左返回
    UIImageView * image_LeftRetrun = [[UIImageView alloc] initWithFrame:CGRectMake(11, 31.5, 25, 25)];
    image_LeftRetrun.userInteractionEnabled = YES;
    image_LeftRetrun.image = [UIImage imageNamed:@"Left-return.png"];
    [_topView addSubview:image_LeftRetrun];
    
    UILabel * lbl_return = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_LeftRetrun.frame) - 6, 35, 35, 15)];
    lbl_return.text = @"返回";
    lbl_return.textColor = [UIColor whiteColor];
    lbl_return.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:lbl_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 22, 60, 40);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64) style:(UITableViewStylePlain)];
    self.tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //头视图
    [self p_headView];
    self.tableView.tableHeaderView = self.view_Head;
    self.tableView.tableFooterView = [[UIView alloc] init];
    [self.view addSubview:self.tableView];
    
    //注册
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"BankCard"];
}

#pragma mark - tableview代理
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 0;
}

- (CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 150;
}

- (UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"BankCard" forIndexPath:indexPath];
    
    return cell;
}

- (void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - 点击添加银行卡
- (void )view_BGAction:(UIButton *)sender
{//NSLog(@"点击添加银行卡");
    Add_BankCardViewController * add_BankCardViewController = [[Add_BankCardViewController alloc] init];
    [self showViewController:add_BankCardViewController sender:nil];
}

#pragma mark - 头视图
- (void )p_headView
{
    self.view_Head = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150)];
    self.view_Head.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    //点击添加银行卡
    UIButton * view_BG = [UIButton buttonWithType:(UIButtonTypeCustom)];
    view_BG.frame = CGRectMake(10, 10, SCREEN_WIDTH - 20, 130);
    view_BG.backgroundColor = [UIColor groupTableViewBackgroundColor];
    view_BG.layer.cornerRadius = 5;
    view_BG.layer.borderColor = [UIColor colorWithRed:90/255.0 green:167/255.0 blue:239/255.0 alpha:1.0].CGColor;
    view_BG.layer.borderWidth = 1;
    [self.view_Head addSubview:view_BG];
    [view_BG addTarget:self action:@selector(view_BGAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    UIImageView * image_add = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 20) / 2 - 60, 65 - 15, 30, 30)];
    image_add.image = [UIImage imageNamed:@"BankCard_card.png"];
    [view_BG addSubview:image_add];
    
    UILabel * lbl_add = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_add.frame) + 10, 65 - 7.5, 100, 15)];
    lbl_add.text = @"添加银行卡";
    lbl_add.textColor = [UIColor colorWithRed:90/255.0 green:167/255.0 blue:239/255.0 alpha:1.0];
    lbl_add.font = [UIFont systemFontOfSize:17.0f];
    [view_BG addSubview:lbl_add];
}












@end
